/* Flash OS Routines (Automagically Generated)
 * Copyright (c) 2009-2015 ARM Limited
 */
#include "flash_blob.h"

static const uint32_t flash_code[] = {
    0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
    0x4770BA40, 0x4770BA40, 0x4770BA40, 0x4770BA40, 0x4770BA40, 0x4770BAC0, 0x4770BAC0, 0x4770BAC0,
    0x4770BAC0, 0x4770BAC0, 0xD1252A01, 0x2100B672, 0x43C94845, 0x48456001, 0x62022255, 0x62816241,
    0x8F4FF3BF, 0x8F6FF3BF, 0xBF00BF00, 0x62412100, 0x62016281, 0x2003493E, 0xF3BF6048, 0xF3BF8F4F,
    0xBF008F6F, 0x483BBF00, 0x0C096841, 0x60410409, 0x4A396841, 0x60414311, 0x47702000, 0x2803B510,
    0x2041D10D, 0x6A810600, 0x29024831, 0x2102D009, 0xF3BF6001, 0xF3BF8F4F, 0xBF008F6F, 0x2000BF00,
    0x2101BD10, 0xF3BF6001, 0xF3BF8F4F, 0xBF008F6F, 0x2201BF00, 0x03522100, 0xF0004608, 0xE7EEF9BE,
    0xF000B510, 0x2000F96B, 0xB510BD10, 0x4611460B, 0xD1072800, 0x6A0C4A21, 0xD0034294, 0x2201620A,
    0x624A03D2, 0x089A1CDB, 0xF97CF000, 0xBD102000, 0x2800B570, 0x4B19D107, 0x429C6A14, 0x6213D003,
    0x03DB2301, 0x23006253, 0x06242441, 0x18C5E006, 0x682D192D, 0x42B558D6, 0x1D1BD102, 0xD3F6428B,
    0xBD7018C0, 0x2200B510, 0x061B2341, 0x1884E007, 0x682418E4, 0xD0011C64, 0xBD102001, 0x428A1D12,
    0x2000D3F5, 0x0000BD10, 0xE000E180, 0x40000700, 0x40000500, 0x4004A000, 0x0000FF18, 0x0B11FFAC,
    0x250FB570, 0xD2092908, 0x008C6806, 0x43AE40A5, 0x68056006, 0x431540A2, 0xE00A6005, 0x460C6846,
    0x00A43C08, 0x43AE40A5, 0x68456046, 0x431540A2, 0x24036045, 0x22010224, 0x1900408A, 0xD0032B00,
    0x43116801, 0xBD706001, 0x43916801, 0xBD706001, 0xB081B5FF, 0x460E4605, 0x49704C6F, 0x1A6A2701,
    0x048814CB, 0xD018428D, 0x496DDC05, 0xD0091869, 0xD1251AC9, 0x1AD1E00A, 0x22BFD016, 0x1A8902D2,
    0xE018D11E, 0x43396881, 0xE0196081, 0x22026881, 0x60814311, 0x34104C60, 0x6881E012, 0x43112204,
    0x4C5D6081, 0xE00B3420, 0x22086881, 0x60814311, 0x34304C59, 0x68C1E004, 0x60C14339, 0x34404C56,
    0x22002301, 0x46204631, 0xFF9AF7FF, 0x99032001, 0x290140B0, 0x6869D01E, 0x60694381, 0x29019904,
    0x1DE1D01C, 0x680A31F9, 0x600A4382, 0x2901990A, 0x1DE1D01A, 0x31FA31FF, 0x4382680A, 0x2101600A,
    0x02899A0B, 0xD0162A01, 0x680A1861, 0x600A4382, 0xBDF0B005, 0x43016869, 0xE7DF6069, 0x31F91DE1,
    0x4302680A, 0xE7E1600A, 0x31FF1DE1, 0x680A31FA, 0x600A4302, 0x1861E7E3, 0x4302680A, 0xE7E7600A,
    0x23016802, 0x431A408B, 0x47706002, 0x23016802, 0x439A408B, 0x47706002, 0x23016802, 0x405A408B,
    0x47706002, 0x40C86B00, 0x0FC007C0, 0x23104770, 0x4A2C1A9B, 0x680340DA, 0x4313408A, 0x47706003,
    0x1A9B2310, 0x40DA4A27, 0x408A6803, 0x60034393, 0x23104770, 0x4A231A9B, 0x680340DA, 0x4053408A,
    0x47706003, 0x1A9B2310, 0x40DA4A1E, 0x40C86B00, 0x47704010, 0x00892201, 0x64021808, 0x22004770,
    0x18080089, 0x47706402, 0x18080089, 0x22016C01, 0x64011A51, 0x23104770, 0x4A121A9B, 0xB67240DA,
    0x408A6803, 0x60034313, 0x4770B662, 0x1A9B2310, 0x40DA4A0C, 0x6803B672, 0x4393408A, 0xB6626003,
    0x23104770, 0x4A071A9B, 0xB67240DA, 0x408A6803, 0x60034053, 0x4770B662, 0x400A0000, 0x40041000,
    0xBFFC0000, 0x0000FFFF, 0x68414833, 0x04090C09, 0x68416041, 0x43114A31, 0x47706041, 0x492EB672,
    0x68086188, 0x01000900, 0x68086008, 0x43104A2C, 0x20206008, 0x20016248, 0x69486148, 0xD1FC2800,
    0x22016808, 0x43900312, 0x68C86008, 0xD5010780, 0xE0052002, 0x074068C8, 0x2001D501, 0x2000E000,
    0x4770B662, 0xB672B5F0, 0x68334E1B, 0x03242401, 0x60334323, 0x27412300, 0xE005063F, 0x590D009C,
    0x19E41824, 0x1C5B6025, 0xD3F74293, 0xBF00E000, 0x07C068B0, 0x6830D1FB, 0x03092101, 0x60304388,
    0x078068F0, 0x2002D501, 0x68F0E005, 0xD5010740, 0xE0002001, 0xB6622000, 0xB570BDF0, 0x25412300,
    0xE005062D, 0x1826009C, 0x68361976, 0x1C5B510E, 0xD3F74293, 0x0000BD70, 0x4004A000, 0x0000FFFF,
    0x00001027, 0x2501B5F8, 0x682807AD, 0x07C34CA3, 0x4AA0499F, 0x444C48A0, 0x6809D006, 0xD5010789,
    0xE0346022, 0xE0326020, 0x267D682B, 0x0F5F06DB, 0x003B0236, 0xF954F000, 0x1C060405, 0x0025201E,
    0xE01E6026, 0x33404B92, 0x079B681B, 0x6809D506, 0xD5010789, 0xE0026022, 0xE0006020, 0x21066020,
    0xF0006820, 0x2178F927, 0x08C04348, 0xE0086020, 0xE0066026, 0xE0046020, 0x68086020, 0xD5000780,
    0x68286022, 0xD5020780, 0x08C06820, 0x49846020, 0xF0006820, 0x6060F90F, 0x497DBDF8, 0x60082001,
    0x680A0781, 0x600A4302, 0xB5004770, 0xFFF5F7FF, 0x6A014877, 0x321222FF, 0x62014311, 0x217D2000,
    0xBF0000C9, 0x42881C40, 0x2101D3FB, 0x60410788, 0x221C6801, 0x60014391, 0x22086801, 0x60014311,
    0x22026801, 0x60014391, 0x08496801, 0x60010049, 0xB500BD00, 0xFFD1F7FF, 0x21014865, 0x61013040,
    0x60410600, 0x221C6801, 0x60014391, 0x60016801, 0x22026801, 0x60014391, 0x08496801, 0x60010049,
    0x485BBD00, 0x60022201, 0x30404859, 0x23026801, 0x60014319, 0x4B5B6841, 0x60414019, 0x4B5A6841,
    0x60414319, 0x23046801, 0x60014399, 0x290068C1, 0x6801D0FC, 0x60014311, 0xB5104770, 0xF7FF4604,
    0xF7FFFF9C, 0x2001FFDE, 0x60480781, 0x221C6808, 0x60084390, 0x22046808, 0x60084310, 0x2C002202,
    0x6808D003, 0x60084310, 0x6808E002, 0x60084390, 0x08406808, 0x60080040, 0xB570BD10, 0xF7FF4604,
    0x4D42FF7C, 0x22072300, 0x46282101, 0xFDA8F7FF, 0x22072300, 0x46284619, 0xFDA2F7FF, 0x6A014834,
    0x43114A3B, 0x21006201, 0x00C0207D, 0x1C49BF00, 0xD3FB4281, 0x07882101, 0x68016041, 0x4391221C,
    0x68016001, 0x4311220C, 0x21026001, 0xD0032C00, 0x430A6802, 0xE0026002, 0x438A6802, 0x68016002,
    0x00490849, 0xBD706001, 0x20034921, 0x04486008, 0x22016801, 0x60014311, 0xB5004770, 0xFFF4F7FF,
    0x07882101, 0x68016041, 0x4391221C, 0x68016001, 0x43112210, 0x68016001, 0x43112202, 0x68016001,
    0x00490849, 0xBD006001, 0xF7FFB500, 0x2101FF26, 0x60410788, 0x221C6801, 0x60014391, 0x22106801,
    0x60014311, 0x22026801, 0x60014311, 0x08496801, 0x60010049, 0xB510BD00, 0x07802001, 0x11426881,
    0x60814311, 0xFFC0F7FF, 0xFEBCF7FF, 0x0000BD10, 0x400AA000, 0x02DC6C00, 0x016E3600, 0x00000004,
    0x000F4240, 0xFCE0FE00, 0x0006001E, 0x400A0020, 0x00070022, 0x460BB530, 0x20004601, 0x24012220,
    0x460DE009, 0x429D40D5, 0x461DD305, 0x1B494095, 0x40954625, 0x46151940, 0x2D001E52, 0xBD30DCF1,
    0x4674B430, 0x78251E64, 0x42AB1C64, 0x461DD200, 0x005B5D63, 0xBC3018E3, 0x00004718, 0x00000000,
    0x016E3600, 0x00000018
};

const program_target_t flash_algo = {
    0x20000049,  // Init
    0x2000009D,  // UnInit
    0x12000001F,  // EraseChip
    0x200000E1,  // EraseSector
    0x200000EB,  // ProgramPage

    // BKPT : start of blob + 1
    // RSB  : address to access global/static data
    // RSP  : stack pointer
    {
        0x20000001,
        0x2000077C,
        0x20000C88
    },

    0x20000788,  // mem buffer location
    0x20000000,  // location to write prog_blob in target RAM
    sizeof(flash_code),  // prog_blob size
    flash_code,  // address of prog_blob
    0x00000100,  // ram_to_flash_bytes_to_be_written
};
